package com.rop.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.rop.model.system.SysOperLog;
import com.rop.model.vo.SysOperaLogQueryVo;
import com.rop.result.Result;
import com.rop.system.service.AsyncOperationLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: SysOperateLogController
 * @Author Rop
 * @Date 2023/5/16 16:49
 * @description: 操作日志接口
 */

@Api(tags = "操作日志接口")
@Slf4j
@RestController
@RequestMapping("admin/system/sysOperate")
public class SysOperateLogController {

    @Autowired
    private AsyncOperationLogService sysOperateLogService;

    /**
     * 分页列表查询
     * @param page 页数
     * @param limit ""
     * @param sysOperaLogQueryVo vo
     * @return ""
     */
    @ApiOperation("获取分页列表")
    @GetMapping("{page}/{limit}")
    public Result<IPage<SysOperLog>> index(@PathVariable Long page,
                                            @PathVariable Long limit,
                                            SysOperaLogQueryVo sysOperaLogQueryVo) {
        IPage<SysOperLog> pageModel = sysOperateLogService.selectPage(page, limit, sysOperaLogQueryVo);
        return Result.ok(pageModel);
    }

    @ApiOperation("根据id获取操作日志")
    @GetMapping("get/{id}")
    public Result<SysOperLog> get(@PathVariable Long id) {
        SysOperLog sysOperLog = sysOperateLogService.getById(id);
        return Result.ok(sysOperLog);
    }
}
